package com.demo.service.uiv.impl;

import com.demo.common.constant.type.UivCatalogTypeConstant;
import com.demo.dao.uiv.entity.UivComponentNode;
import com.demo.dao.uiv.mapper.*;
import com.demo.dao.uiv.model.*;
import com.demo.service.uiv.UivBasicVOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UivBasicVOServiceImpl implements UivBasicVOService {
    @Autowired
    private UivMenuTreeVOMapper menuTreeVOMapper;

    @Autowired
    private UivProjectTreeVOMapper projectTreeVOMapper;

    @Autowired
    private UivPageTreeVOMapper pageTreeVOMapper;

    @Autowired
    private UivModTreeVOMapper modTreeVOMapper;

    @Autowired
    private UivDictionaryTypeTreeVOMapper dictionaryTypeTreeVOMapper;

    @Autowired
    private UivHmiComponentNodeMapper componentNodeMapper;

    @Autowired
    private UivTupleItemMapper tupleItemMapper;

    @Autowired
    private UivVarItemVOMapper varItemVOMapper;

    
    //菜单列表树
    public List<UivMenuTreeItemVO> getMenuVOTree() {
        return menuTreeVOMapper.getComponentTypeVOTree();
    }

    //项目列表树
    public List<UivProjectTreeItemVO> getProjectVOTree() {
        return projectTreeVOMapper.getProjectVOTree();
    }

    //页面列表树
    public List<UivPageTreeItemVO> getPageVOTree() {
        return pageTreeVOMapper.getPageVOTree();
    }

    //模板列表树
    public List<UivModTreeItemVO> getModVOTree() {
        return modTreeVOMapper.getModVOTreeByTypeName(UivCatalogTypeConstant.FIELD_TYPE_CODE);
    }

    //数据字典类型树
    public List<UivDictionaryTypeTreeItemVO> getDictionaryTypeVOTree(Long id) {
        return dictionaryTypeTreeVOMapper.getDictionaryTypeVOTreeById(id);
    }

    //读取组件树
    public UivComponentNode getComponentNodeById(Long id) {
        UivComponentNode uivComponentNode = componentNodeMapper.getComponentNodeById(id);
        return componentNodeMapper.getComponentNodeById(id);
    }

    //根据Url查询图元
    public List<UivTupleItemVO> getTupleByURL(String url) {
        return tupleItemMapper.getTupleByURL(url);
    }

    //根据项目ID读取变量
    public List<UivVariableNodeItemVO> getVarItemVOByParam(UivQueryItemVO param) {
        return varItemVOMapper.getVarItemVOByParam(param);
    }

    //根据变量ID读取相关信息
    public List<UivVariableItemVO> getVarItemVOById(Long id) {
        return varItemVOMapper.getVarItemVOById(id);
    }
}
